﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Drawing.Printing;
using System.Drawing;
namespace BISPOS
{

    public class PrintTextDocument
    {
        public PrintDocument pPd;
        public string[] pLineas { get; set; }   //Lines
        private Font pFont;


        public PrintTextDocument(string[] lineas, Font fuente)
        {
            pLineas = lineas;
            pFont = fuente;

            pPd = new PrintDocument();
            pPd.DefaultPageSettings.PrinterResolution.Kind = PrinterResolutionKind.High;
            pPd.PrintPage += new PrintPageEventHandler(pPd_PrintPage);
        }

        void pPd_PrintPage(object sender, PrintPageEventArgs e)
        {
            float yPos;
            int count = 0;
            float leftMargin = 0;// e.MarginBounds.Left;
            float topMargin = 0;// e.MarginBounds.Top;
            string line;

            e.Graphics.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
            for (int i = 0; i < pLineas.Length; i++)
            {
                line = pLineas[i];

                yPos = topMargin + count * pFont.GetHeight(e.Graphics);
                e.Graphics.DrawString(line, pFont, Brushes.Black, leftMargin, yPos, new StringFormat());
                count++;
            }
        }

        public void Print()
        {
            pPd.Print();

        }

    }
}
